package com.tau.egonetwork.profiles;

public class Group<T extends Comparable<T>> extends FriendsList<T> implements Cloneable {
	
	private static final long serialVersionUID = 6571291595761677002L;
	
	private String _name;
	
	public Group(String name) {
		super();
		this._name = name;
	}
	
	public void setGroupName(String name) {
		this._name = name;
	}
	
	public String getGroupName() {
		return _name;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Object clone() {
		Group<T> g = (Group<T>)super.clone();
		g.clear();
		return g;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public boolean equals(Object arg0) {
		
		if (!(arg0 instanceof Group<?>))
			return false;
		
		Group<T> obj = (Group<T>)arg0;
		
		if (!_name.equals(obj.getGroupName()))
			return false;

		for (Profile<T> m : this) {
			if (!obj.contains(m))
				return false;
		}
		
		return true;
	}
}
